import {RouteRecordRaw, RouterView} from 'vue-router'
import {h} from 'vue'
import Login from 'pages/auth/Login.vue'

import 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    component: () => import('layouts/MainLayout.vue'),
    children: [
      {path: '', component: () => import('pages/Index.vue')},
      {
        name: '/comm/my/my-profile',
        path: '/comm/my/my-profile',
        component: () => import('pages/my/MyProfile.vue'),
      },
      {name: '/comm/my/message', path: '/comm/my/message', component: () => import('../lib/pages/my/Message.vue')},
      {name: '/comm/cfg/about', path: '/comm/cfg/about', component: () => import('pages/cfg/About.vue')},

      // 公司管理
      {
        path: '/comm/basic/company',
        component: {render: () => h(RouterView)},
        children: [
          // 查看公司列表
          {
            name: '/comm/basic/company',
            path: '',
            component: () => import('../lib/pages/basic/CompanyList.vue'),
            meta: {needRight: 'Comm.Company.View'},
          },
          // 创建公司
          {
            name: '/comm/basic/company/create',
            path: 'create',
            component: () => import('../lib/pages/basic/Company.vue'),
            meta: {needRight: 'Comm.Company.Edit'},
          },
          // 修改公司
          {
            name: '/comm/basic/company/edit',
            path: 'edit/:itemId',
            component: () => import('../lib/pages/basic/Company.vue'),
            meta: {needRight: 'Comm.Company.Edit'},
          },
          // 查看单个公司
          {
            name: '/comm/basic/company/detail',
            path: 'detail/:itemId',
            component: () => import('../lib/pages/basic/Company.vue'),
            meta: {needRight: 'Comm.Company.View'},
          },
        ],
      },
      // 用户管理
      {
        path: '/comm/cfg/user',
        component: {render: () => h(RouterView)},
        children: [
          // 查看用户列表
          {
            name: '/comm/cfg/user',
            path: '',
            component: () => import('../pages/cfg/UserList.vue'),
            meta: {needRight: 'Comm.UserMgr.View'},
          },
          // 创建用户
          {
            name: '/comm/cfg/user/create',
            path: 'create',
            component: () => import('../pages/cfg/User.vue'),
            meta: {needRight: 'Comm.UserMgr.Edit'},
          },
          // 修改用户
          {
            name: '/comm/cfg/user/edit',
            path: 'edit/:itemId',
            component: () => import('../pages/cfg/User.vue'),
            meta: {needRight: 'Comm.UserMgr.Edit'},
          },
          // 查看单个用户
          {
            name: '/comm/cfg/user/detail',
            path: 'detail/:itemId',
            component: () => import('../pages/cfg/User.vue'),
            meta: {needRight: 'Comm.UserMgr.View'},
          },
        ],
      },
      // 汇率管理
      {
        path: '/comm/basic/exchange',
        component: {render: () => h(RouterView)},
        children: [
          // 查看汇率列表
          {
            name: '/comm/basic/exchange',
            path: '',
            component: () => import('../lib/pages/basic/ExchangeList.vue'),
            meta: {needRight: 'Comm.Exchange.View'},
          },
          // 创建汇率
          {
            name: '/comm/basic/exchange/create',
            path: '/comm/basic/exchange/create',
            component: () => import('../lib/pages/basic/Exchange.vue'),
            meta: {needRight: 'Comm.Exchange.Edit'},
          },
          // 查看汇率
          {
            name: '/comm/basic/exchange/detail',
            path: '/comm/basic/exchange/detail/:itemId',
            component: () => import('../lib/pages/basic/Exchange.vue'),
            meta: {needRight: 'Comm.Exchange.View'},
          },
          // 编辑汇率
          {
            name: '/comm/basic/exchange/edit',
            path: '/comm/basic/exchange/edit/:itemId',
            component: () => import('../lib/pages/basic/Exchange.vue'),
            meta: {needRight: 'Comm.Exchange.Edit'},
          },
        ],
      },
      // 客商管理
      {
        path: '/comm/basic/mf',
        component: {render: () => h(RouterView)},
        children: [
          // 查看客商列表
          {
            name: '/comm/basic/mf',
            path: '',
            component: () => import('../pages/basic/MfList.vue'),
            meta: {needRight: 'Comm.Mf.View'},
          },
          // 创建客商
          {
            name: '/comm/basic/mf/create',
            path: '/comm/basic/mf/create',
            component: () => import('../pages/basic/Mf.vue'),
            meta: {needRight: 'Comm.Mf.Edit'},
          },
          // 查看客商
          {
            name: '/comm/basic/mf/detail',
            path: '/comm/basic/mf/detail/:itemId',
            component: () => import('../pages/basic/Mf.vue'),
            meta: {needRight: 'Comm.Mf.View'},
          },
          // 编辑客商
          {
            name: '/comm/basic/mf/edit',
            path: '/comm/basic/mf/edit/:itemId',
            component: () => import('../pages/basic/Mf.vue'),
            meta: {needRight: 'Comm.Mf.Edit'},
          },
        ],
      },
      // 角色权限
      {
        path: '/comm/cfg/roleright',
        component: {render: () => h(RouterView)},
        children: [
          // 查看角色权限列表
          {
            name: '/comm/cfg/roleright',
            path: '',
            component: () => import('../lib/pages/cfg/RoleRightList.vue'),
            meta: {needRight: 'Comm.RoleRight.View'},
          },
          // 创建角色权限
          {
            name: '/comm/cfg/roleright/create',
            path: '/comm/cfg/roleright/create',
            component: () => import('../pages/cfg/RoleRight.vue'),
            meta: {needRight: 'Comm.RoleRight.Edit'},
          },
          // 查看角色权限
          {
            name: '/comm/cfg/roleright/detail',
            path: '/comm/cfg/roleright/detail/:itemId',
            component: () => import('../pages/cfg/RoleRight.vue'),
            meta: {needRight: 'Comm.RoleRight.View'},
          },
          // 编辑角色权限
          {
            name: '/comm/cfg/roleright/edit',
            path: '/comm/cfg/roleright/edit/:itemId',
            component: () => import('../pages/cfg/RoleRight.vue'),
            meta: {needRight: 'Comm.RoleRight.Edit'},
          },
        ],
      },
      // 代码设置
      {
        path: '/comm/cfg/code',
        component: {render: () => h(RouterView)},
        children: [
          // 查看代码设置列表
          {
            name: '/comm/cfg/code',
            path: '',
            component: () => import('../lib/pages/cfg/CodeList.vue'),
            meta: {needRight: 'Comm.Code.View'},
          },
          // 查看代码设置
          {
            name: '/comm/cfg/code/detail',
            path: '/comm/cfg/code/detail/:itemId',
            component: () => import('../lib/pages/cfg/Code.vue'),
            meta: {needRight: 'Comm.Code.View'},
          },
        ],
      },
      // 文件管理
      {
        name: '/comm/cfg/fms',
        path: '/comm/cfg/fms',
        component: () => import('../lib/pages/cfg/Fms.vue'),
        meta: {needRight: 'Comm.Fms.Management'},
      },
      // 更新记录
      {
        name: '/comm/cfg/updaterecord',
        path: '/comm/cfg/updaterecord',
        component: () => import('../lib/pages/sys/UpdateRecord.vue'),
      },

      // DEMO
      {
        name: '/demo/simplefilterselect',
        path: '/demo/simplefilterselect',
        component: () => import('pages/demo/SimpleFilterSelectDemo.vue'),
      },
      {
        name: '/demo/qeditor',
        path: '/demo/qeditor',
        component: () => import('pages/demo/QEditorDemo.vue')
      },
      {
        name: '/demo/rightsdemo',
        path: '/demo/rightsdemo',
        component: () => import('pages/demo/RightsDemo.vue')
      },
      {
        name: '/demo/miscdemo',
        path: '/demo/miscdemo',
        component: () => import('pages/demo/MiscDemo.vue'),
      },
      {
        name: '/demo/timePickDemo',
        path: '/demo/timePickDemo',
        component: () => import('pages/demo/TimePickDemo.vue'),
      },
      {
        name: '/demo/focusnextdemo',
        path: '/demo/focusnextdemo',
        component: () => import('pages/demo/FocusNextTestDemo.vue'),
      },
      {
        name: '/demo/shoppingcartdemo',
        path: '/demo/shoppingcartdemo',
        component: () => import('pages/demo/ShoppingCartDemo.vue'),
      },
      {
        name: '/demo/collectionval',
        path: '/demo/collectionval',
        component: () => import('pages/demo/CollectionValDemo.vue'),
      },
      {
        name: '/demo/datatabledemo',
        path: '/demo/datatabledemo',
        component: () => import('pages/demo/DatatableDemo.vue'),
      },
      {
        name: '/demo/icons',
        path: '/demo/icons',
        component: () => import('pages/demo/Icons.vue'),
      },
      {
        name: '/demo/layout',
        path: '/demo/layout',
        component: () => import('pages/demo/Layout.vue'),
      },
      {
        name: '/demo/color',
        path: '/demo/color',
        component: () => import('pages/demo/Color.vue'),
      },
      {
        name: '/demo/text',
        path: '/demo/text',
        component: () => import('pages/demo/TextDemo.vue'),
      },
      {
        name: '/demo/wfrchartdemo',
        path: '/demo/wfrchartdemo',
        component: () => import('pages/demo/WfrChartDemo.vue'),
      },
      {
        name: '/demo/i18ndemo',
        path: '/demo/i18ndemo',
        component: () => import('pages/demo/I18nDemo.vue'),
      },
      // 代码设置
      {
        path: '/demo/line-fps-helper-demo',
        component: {render: () => h(RouterView)},
        children: [
          // 查看代码设置列表
          {
            name: '/demo/line-fps-helper-demo',
            path: '',
            component: () => import('pages/demo/LineFpsHelperListDemo.vue'),
          },
          // 查看代码设置
          {
            name: '/demo/line-fps-helper-demo/detail',
            path: 'detail/:itemId',
            component: () => import('pages/demo/LineFpsHelperDemo.vue'),
          },
        ],
      },
    ],
  },
  {
    path: '/',
    component: () => import('layouts/CenterBoxLayout.vue'),
    children: [
      {
        name: '/comm/auth/login',
        path: '/comm/auth/login',
        component: Login,
        meta: {needLogin: false},
      },
      {
        name: '/comm/auth/forgot-password',
        path: '/comm/auth/forgot-password',
        component: () => import('pages/auth/ForgotPassword.vue'),
        meta: {needLogin: false},
      },
      {
        name: '/comm/auth/reset-password',
        path: '/comm/auth/reset-password',
        component: () => import('pages/auth/ResetPassword.vue'),
        meta: {needLogin: false},
      },
      {
        name: '/comm/auth/renew-password',
        path: '/comm/auth/renew-password',
        component: () => import('pages/auth/ResetPassword.vue'),
        meta: {needLogin: false},
      },
      {
        name: '/comm/auth/set-password-first-time',
        path: '/comm/auth/set-password-first-time',
        component: () => import('pages/auth/ResetPassword.vue'),
        meta: {needLogin: false},
      },
      {
        name: '/comm/auth/change-password',
        path: '/comm/auth/change-password',
        component: () => import('pages/auth/ChangePassword.vue'),
      },
      {
        name: '/comm/auth/authorize-callback',
        path: '/comm/auth/authorize-callback',
        component: Login,
        meta: {needLogin: false},
      },
    ],
  },
  // Always leave this as last one,
  // but you can also remove it
  {
    path: '/:catchAll(.*)*',
    component: () => import('../lib/pages/sys/Error404.vue'),
  },
]

export default routes
